import os
from datetime import timedelta

# 数据库配置
DB_USERNAME = "root"
DB_PASSWORD = "root"
DB_HOST = "127.0.0.1"
DB_PORT = "3306"
DB_NAME = "pythonbbs"
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://%s:%s@%s:%s/%s?charset=utf8mb4" % (
    DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME)
SQLALCHEMY_TRACK_MODIFICATION = False

# 配置Mail信息
MAIL_SERVER = 'smtp.qq.com'
MAIL_PORT = 587  # 465
MAIL_USE_TLS = True
MAIL_USERNAME = ''
MAIL_PASSWORD = ''
MAIL_DEFAULT_SENDER = ''

# celery配置redis发送邮件
CELERY_BROKER_URL = "redis://127.0.0.1:6379/0"
CELERY_RESULT_BACKEND = "redis://127.0.0.1:6379/0"

# Flask-Caching的配置
CACHE_TYPE = "RedisCache"
CACHE_DEFAULT_TIMEOUT = 300
CACHE_REDIS_HOST = "127.0.0.1"
CACHE_REDIS_PORT = 6379

# 配置CSRF_TOKEN的key
# SECRET_KEY = "ddasgfdsgdfg"  # 开发环境中写死,方便测试
SECRET_KEY = os.urandom(24)

# 图形验证码中需要使用的BASE_DIR
BASE_DIR = os.path.dirname(__file__)  # 获取当前项目的根路径

# session.permanent=True的情况下的过期时间
PERMANENT_SESSION_LIFETIME = timedelta(days=31)

# avatars头像配置 保存地址(当前项目/media/avatars/中)
AVATARS_SAVE_PATH = os.path.join(BASE_DIR, "media", "avatars")
# 帖子图片存放路径
POST_IMAGE_SAVE_PATH = os.path.join(BASE_DIR, "media", "post")
# 轮播图图片存放路径
BANNER_IMAGE_SAVE_PATH = os.path.join(BASE_DIR, "media", "banner")

# 配置帖子分页
PER_PAGE_COUNT = 10

# 设置WTF过期时间
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=7)
